package day15.test03;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @author Xiao
 * @date 2021/8/9
 */
public class Server03 {
    /**
     * 3. 使用UDP协议完成数据传输
     *     发送端发送，接收端接收
     */
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(12345);
        byte[] bytes = new byte[1024];
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length);
        ds.receive(dp);
        System.out.println(new String(dp.getData(),0,dp.getLength()));
        ds.close();
    }
}
